from DoseStat import *
from collections import Vector
from math import f64, max, min

def main():
    # 模拟数据
    voxel_volume = Vector[f64]([1.0, 2.0, 3.0, 4.0, 5.0])
    voxel_dose = Vector[f64]([10.0, 20.0, 30.0, 40.0, 50.0])
    
    print("Testing Dose Statistics Functions")
    print("==================================")
    
    # 测试Accumulate函数
    print("\n1. Testing Accumulate function...")
    result = Accumulate(voxel_volume, voxel_dose, False)
    
    # 测试GetMetric函数
    print("\n2. Testing GetMetric function...")
    d98 = GetMetric(0.98, result.binned_dose_values, result.accumulated_relative_volumes)
    print("   D_98 = {} Gy".format(d98))
    d95 = GetMetric(0.95, result.binned_dose_values, result.accumulated_relative_volumes)
    print("   D_95 = {} Gy".format(d95))
    d50 = GetMetric(0.5, result.binned_dose_values, result.accumulated_relative_volumes)
    print("   D_50 = {} Gy".format(d50))
    
    # 测试GetDoseStatRoiInterp函数
    print("\n3. Testing GetDoseStatRoiInterp function...")
    # 测试平均剂量
    average_dose = GetDoseStatRoiInterp("average", result.binned_dose_values, result.accumulated_relative_volumes, voxel_volume, voxel_dose)
    print("   Average Dose = {} Gy".format(average_dose))
    # 测试D_95
    d95_alt = GetDoseStatRoiInterp("D_95", result.binned_dose_values, result.accumulated_relative_volumes, voxel_volume, voxel_dose)
    print("   D_95 (via interp) = {} Gy".format(d95_alt))
    # 测试自定义DoseAtVolume
    dose_at_70 = GetDoseStatRoiInterp("DoseAtVolume", result.binned_dose_values, result.accumulated_relative_volumes, voxel_volume, voxel_dose, 0.7)
    print("   Dose at 70% Volume = {} Gy".format(dose_at_70))

if __name__ == "__main__":
    main()